package com.eningqu.aipen.ui.adapter;/**
 * Package:com.eningqu.aipen.ui.adapter
 * Author:starr
 * Time:2023/11/7 11:00
 * Description:
 */

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

/**
 * Package:com.eningqu.aipen.ui.adapter
 * Author:starr
 * Time:2023/11/7 11:00
 * Description: MainActivity上承载ViewPager2的Fragment适配器
 */
public class FragmentStateVPAdapter extends FragmentStateAdapter {
    private List<Fragment> list;

    public FragmentStateVPAdapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> list) {
        super(fragmentActivity);
        this.list = list;
    }

    @NonNull
    @Override
    public Fragment createFragment(int i) {
        return list.get(i);
    }

    @Override
    public int getItemCount() {
        return list != null ? list.size() : 0;
    }
}
